package org.dromara.school.service.impl;

import com.github.yulichang.wrapper.MPJLambdaWrapper;
import lombok.RequiredArgsConstructor;
import org.dromara.school.domain.BindingSchools;
import org.springframework.stereotype.Service;
import org.dromara.school.domain.TeacherDiscipline;
import org.dromara.school.mapper.TeacherDisciplineMapper;
import org.dromara.school.service.ITeacherDisciplineService;
import com.github.yulichang.base.MPJBaseServiceImpl;
import java.util.List;
import java.util.Map;
import java.util.Collection;

/**
 * 教师绑定学科Service业务层处理
 *
 * @author Gjb
 * @date 2025-06-13
 */
@RequiredArgsConstructor
@Service
public class TeacherDisciplineServiceImpl  extends MPJBaseServiceImpl<TeacherDisciplineMapper,TeacherDiscipline> implements ITeacherDisciplineService {

    private final TeacherDisciplineMapper baseMapper;



    /**
     * 根据教师id 获取所有绑定信息
     * @param tid
     * @return
     */
    @Override
    public List<TeacherDiscipline> findByTeacherId(Long tid) {
        MPJLambdaWrapper<TeacherDiscipline> mpj = new MPJLambdaWrapper<TeacherDiscipline>();
        mpj.selectAll(TeacherDiscipline.class)
            .eq(TeacherDiscipline::getTeacherId,tid);
        return  baseMapper.selectList(mpj);
    }

    @Override
    public int insert(TeacherDiscipline teacherDiscipline) {

        return this.baseMapper.insert(teacherDiscipline);
    }

    @Override
    public int deleteByTeacherId(Long tid) {
        MPJLambdaWrapper<TeacherDiscipline> mpj = new MPJLambdaWrapper<TeacherDiscipline>();
        mpj.eq(BindingSchools::getTeacherId,tid);
        return baseMapper.deleteJoin(mpj);
    }


}
